﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using WinFormsApp1.Common;
using System.ComponentModel.DataAnnotations;
using System.Drawing.Printing;
using System.Reflection.Emit;
using WinFormsApp1.Leo.week02;

namespace WinFormsApp1.SuYi.Week2WinForm
{
    public partial class WeighingSheetWinForm : Form
    {
        public WeighingSheetWinForm()
        {
            InitializeComponent();
            LoadDatetime();

        }
        public class PiGroup
        {
            public DateTime SlaughterDate { get; set; }
            public int SlaughterMaxNum { get; set; }
            public int zhongliang { get; set; }
            public int num { get; set; }
        }
        /// <summary>
        /// 加载 根据时间分组统计  批宰的数量及重量
        /// </summary>
        public async void LoadDatetime()
        {
            var data = new
            {
            };
            var items = await HttpClientHelper.RequestUrl<object, ApiResult<List<PiGroup>>>(URLCommon.Url2, "/Week2Get/TimeGroupPlan", HttpClientHelper.MethodType.POST, data);
            this.dataGridView1.DataSource = items.Data;

        }

        /// <summary>
        /// 点击获取 当天 的批宰列表
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            //MessageBox.Show(e.ColumnIndex.ToString() + "---" + e.RowIndex.ToString());
            //获取选中行指定列的值
            //MessageBox.Show(dataGridView1.Rows[e.RowIndex].Cells["SlaughterDate"].Value.ToString());

            WeighingSheet.SlaughterDate = dataGridView1.Rows[e.RowIndex].Cells["SlaughterDate"].Value.ToString();
            WeighingSheet.Column1 = Convert.ToString(dataGridView1.Rows[e.RowIndex].Cells["Column1"].Value);
            AddWeighingSheetWinForm addWeighingSheetWinForm = new AddWeighingSheetWinForm();
            //显示副宰新增页面
            addWeighingSheetWinForm.Show();

            //uiTextBox1.Text = num;
            //label2.Text = date.ToString("yyyy-MM-dd");
            //var data = new
            //{
            //    date
            //};
            //var items = await HttpClientHelper.RequestUrl<object, ApiResult<List<NoData>>>("http://localhost:5106/api/Week2Get/", "SlaughterEveryDayGroup", HttpClientHelper.MethodType.POST, data);
            //this.dataGridView2.DataSource = items.Data;
        }

        /// <summary>
        /// 添加点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void uiButton1_Click(object sender, EventArgs e)
        {


        }


        /// <summary>
        /// 副产称重字段
        /// </summary>
        public class WeighingSheetsDto
        {
            /// <summary>
            /// 称重时间
            /// </summary>
            public DateTime WeighDate { get; set; }
            /// <summary>
            /// 计划号
            /// </summary>
            public string ProjectNo { get; set; }
            /// <summary>
            /// 仓库
            /// </summary>
            public int DepotId { get; set; }
            /// <summary>
            /// 皮重
            /// </summary>
            public decimal SkinWeight { get; set; }
            /// <summary>
            /// 毛重
            /// </summary>
            public decimal GrossWeight { get; set; }
            /// <summary>
            /// 屠宰编号
            /// </summary>
            public string SlaughterIds { get; set; }
            /// <summary>
            /// 净重
            /// </summary>
            public decimal NetWeight { get; set; }
            /// <summary>
            /// 数量
            /// </summary>
            public int WeighingSheetsNum { get; set; }
            /// <summary>
            /// 备注
            /// </summary>
            public string WeighingDesc { get; set; }
            /// <summary>
            /// 逻辑删除
            /// </summary>
            public int IsDel { get; set; }
            /// <summary>
            /// 商品代号
            /// </summary>
            public int GoodsMinuteId { get; set; }
        }

        /// <summary>
        /// 定义页面下拉框的数据框架
        /// </summary>
        public class Context
        {
            public int Id { get; set; }
            public string Name { get; set; }
        }

    }
}
